const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    video_list :[
      {
        id:0,
        cover : "/images/new/video_1.png",
        url : "https://baidunzhihu.cn/videos/1.mp4",
        description : "不合理信念 VS 合理信念"
      },
      {
        id:1,
        cover : "/images/new/video_2.png",
        url : "https://baidunzhihu.cn/videos/2.mp4",
        description : "如果你有这六种进食障碍倾向，你就要调整了"
      },
      {
        id:2,
        cover : "/images/new/video_3.png",
        url : "https://baidunzhihu.cn/videos/3.mp4",
        description : "积极的自我对话"
      },
      {
        id:3,
        cover : "/images/new/video_4.png",
        url : "https://baidunzhihu.cn/videos/4.mp4",
        description : "不能对进食障碍患者说或做的五件事"
      },
      {
        id:4,
        cover : "/images/new/video_5.png",
        url : "https://baidunzhihu.cn/videos/5.mp4",
        description : "让自己的内心更强大"
      },
      {
        id:5,
        cover : "/images/new/video_6.png",
        url : "https://baidunzhihu.cn/videos/6.mp4",
        description : "进食障碍治疗"
      },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  onShow() {
    console.log(app.video_info)
    let count = 0;
    app.video_info.forEach(element => {
      if (element) {
        count++
      }
    });

    if (count == 6) {
      wx.showToast({
        icon:"none",
        title: '观看已完成！获得了3份狗粮',
        duration: 3000
      })

      app.video_info = [false,false,false,false,false,false]
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  videoAction(e) {
    const item =  e.currentTarget.dataset.item;
    wx.navigateTo({
      url: '/pages/video/play?url=' + item.url + "&description=" + item.description + "&id=" + item.id,
    })
  }
})